local skel = fk.CreateSkill {
  name = "lb__kanxi",
  tags = { Skill.Compulsory, Skill.Switch },
  max_branches_use_time = function(self, player)
    local list = {}
    for name, card in pairs(Fk.all_card_types) do
      if card.type ~= Card.TypeEquip and not list[name] then
        list[name] = { [Player.HistoryRound] = 1 }
      end
    end
    return list
  end
}

Fk:loadTranslationTable {
  ["lb__kanxi"] = "勘析",
  --[":lb__kanxi"] = "<b>锁定技</b>，<b>转换技</b>，每轮每种牌名限一次，一张牌结算后，若你是使用者或目标，阳：本轮你的攻击范围+1；阴：你摸一张牌。",
  --9.21
  --[":lb__kanxi"] = "<b>锁定技</b>，<b>转换技</b>，每阶段每种牌名限一次，一张非装备牌结算后，若你是使用者或目标，阳：本轮你的攻击范围+1；阴：你摸一张牌。",
  --9.22
  [":lb__kanxi"] = "<b>锁定技</b>，<b>转换技</b>，每轮每种牌名限一次，一张非装备牌结算后，若你是使用者或目标，阳：本轮你的攻击范围+1；阴：你摸一张牌。",

  [":lb__kanxi_yang"] = "<b>锁定技</b>，<b>转换技</b>，每轮每种牌名限一次，一张非装备牌结算后，若你是使用者或目标，<font color=\"#E0DB2F\">阳：本轮你的攻击范围+1；</font>阴：你摸一张牌。",
  [":lb__kanxi_yin"] = "<b>锁定技</b>，<b>转换技</b>，每轮每种牌名限一次，一张非装备牌结算后，若你是使用者或目标，阳：本轮你的攻击范围+1；<font color=\"#E0DB2F\">阴：你摸一张牌。</font>",


  ["@lb__kanxi-round"] = "勘析<font color='red'>+</font>",
  ["@[skill_cardname]lb__kanxi"] = "勘析",

  ["$lb__kanxi1"] = "看什么看！",
  ["$lb__kanxi2"] = "我是黑塔，现在很忙。",
}


skel:addEffect(fk.CardUseFinished, {
  anim_type = "switch",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and (player == data.from or table.contains(data.tos, player))
        and data.card.type ~= Card.TypeEquip
        and skel:withinBranchTimesLimit(player, data.card.trueName, Player.HistoryRound)
  end,
  on_use = function(self, event, target, player, data)
    player:addSkillBranchUseHistory(skel.name, data.card.trueName)
    if player:getSwitchSkillState(skel.name) == fk.SwitchYang then
      player:drawCards(1, skel.name)
    else
      player.room:addPlayerMark(player, "@lb__kanxi-round")
    end
  end,
}, { check_skill_limit = true })

skel:addEffect("atkrange", {
  correct_func = function(self, from, to)
    if from:hasSkill("lb__kanxi") then
      return from:getMark("@lb__kanxi-round")
    end
  end,
})

skel:addAcquireEffect(function(self, player, is_start)
  local names = {}
  for name, card in pairs(Fk.all_card_types) do
    if card.type ~= Card.TypeEquip then
      table.insert(names, name)
    end
  end
  player.room:setPlayerMark(player, "@[skill_cardname]lb__kanxi",
    { name = skel.name, scope = Player.HistoryRound, all_names = names })
end)

skel:addLoseEffect(function(self, player, is_death)
  player.room:setPlayerMark(player, "@[skill_cardname]lb__kanxi", 0)
end)

return skel
